package com.friendc.Util;

import java.sql.*;

public class JdbcUtil {
    /*引入jar文件
     * 1、将jar文件粘贴到WEB-INF/lib文件夹下
     * 2、右键项目-->Build Path-->Configura Build Path-->Add JARS-->选择项目里的jar文件
     * */
    //加载驱动、建立连接
    public Connection getConnection() {
        Connection con = null;
        try {
            String url = "jdbc:mysql://cdb-kthncrwi.bj.tencentcdb.com:10159/xialiao?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true ";
            Class.forName("com.mysql.cj.jdbc.Driver");
            con = DriverManager.getConnection(url,"student","521qianfeng");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return con;
    }

}
